/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSProjectionTechniqueElement.h
 *
 *  Created on: 2010/03/09
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSPROJECTIONTECHNIQUEELEMENT_H_
#define RSPROJECTIONTECHNIQUEELEMENT_H_

#include "RSTechniqueElement.h"
#include <QMatrix4x4>

namespace Realsphere {

    class RSProjectionTechniqueElement : public Realsphere::RSTechniqueElement {
        Q_OBJECT
        public:
            RSProjectionTechniqueElement ( RSProjectionElementType rProjectionElementType,
                                           const QString& rScopeId = QString::null );
            virtual ~RSProjectionTechniqueElement ();

        public:
            RSFloat*                    AspectRatio () const;
            RSFloat*                    ZNear () const;
            RSFloat*                    ZFar () const;

            virtual QMatrix4x4          ProjectionMatrix () const = 0;
            RSProjectionElementType     ProjectionType () const;

            bool                        IsRootElement () const;

        public slots:
            RSError                     SetAspectRatio ( RSFloat* rValue );
            RSError                     SetZNear ( RSFloat* rValue );
            RSError                     SetZFar ( RSFloat* rValue );

            RSError                     SetAspectRatio ( const float& rValue );
            RSError                     SetZNear ( const float& rValue );
            RSError                     SetZFar ( const float& rValue );

            RSError                     SetAspectRatio ( const RSFloat& rValue );
            RSError                     SetZNear ( const RSFloat& rValue );
            RSError                     SetZFar ( const RSFloat& rValue );

        signals:
            void                        AspectRatioAdded ( RSFloat* rAspectRatio );
            void                        AspectRatioRemoved ( RSFloat* rAspectRatio );
            void                        AspectRatioChanged ();

            void                        ZNearAdded ( RSFloat* rZNear );
            void                        ZNearRemoved ( RSFloat* rZNear );
            void                        ZNearChanged ();

            void                        ZFarAdded ( RSFloat* rZNear );
            void                        ZFarRemoved ( RSFloat* rZNear );
            void                        ZFarChanged ();

        protected:
            RSError                     BeforeAddValueElementValidation ( RSValueElement* rValueElement );
            RSError                     BeforeRemoveValueElementValidation ( RSValueElement* rValueElement );
            bool                        AfterAddValueElementValidation ( RSValueElement* rValueElement );
            bool                        AfterRemoveValueElementValidation ( RSValueElement* rValueElement );

        public:
            static QString                 ProjectionElementTypeToTag ( RSProjectionElementType rProjectionElementType );
            static RSProjectionElementType ProjectionElementTagToType ( const QString& rTag );

        private:
            RSFloat*                    mAspectRatio;
            RSFloat*                    mZNear;
            RSFloat*                    mZFar;
            RSProjectionElementType     mProjectionElementType;
    };

}

#endif /* RSPROJECTIONTECHNIQUE_H_ */
